from django import forms

from learning_logs.models import Topic, Entry


class TopicForm(forms.ModelForm):
    class Meta:
        model = Topic
        # 表单中的字段
        fields = ['text', 'detail']
        # 字段label
        labels = {'text': '名字', 'detail': '详情'}


class EntryForm(forms.ModelForm):
    class Meta:
        model = Entry
        # 表单中的字段
        fields = ['text']
        # 字段label
        labels = {'text': ''}
        # 指定输入部件的属性
        widgets = {'text': forms.Textarea(attrs={'cols': 80})}
